package com.ruoyi.quality.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.quality.domain.QualityInnerLoss;
import com.ruoyi.quality.service.IQualityInnerLossService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

/**
 * 内部损失管理Controller
 * 
 * @author wky
 * @date 2024-06-05
 */
@RestController
@RequestMapping("/quality/innerLoss")
@Tag(name = "【内部损失管理】管理")
public class QualityInnerLossController extends BaseController
{
    @Autowired
    private IQualityInnerLossService qualityInnerLossService;

    /**
     * 查询内部损失管理列表
     */
    @Operation(summary = "查询内部损失管理列表")
    @PreAuthorize("@ss.hasPermi('quality:innerLoss:list')")
    @GetMapping("/list")
    public TableDataInfo list(QualityInnerLoss qualityInnerLoss)
    {
        startPage();
        List<QualityInnerLoss> list = qualityInnerLossService.selectQualityInnerLossList(qualityInnerLoss);
        return getDataTable(list);
    }

    /**
     * 导出内部损失管理列表
     */
    @Operation(summary = "导出内部损失管理列表")
    @PreAuthorize("@ss.hasPermi('quality:innerLoss:export')")
    @Log(title = "内部损失管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QualityInnerLoss qualityInnerLoss)
    {
        List<QualityInnerLoss> list = qualityInnerLossService.selectQualityInnerLossList(qualityInnerLoss);
        ExcelUtil<QualityInnerLoss> util = new ExcelUtil<QualityInnerLoss>(QualityInnerLoss.class);
        util.exportExcel(response, list, "内部损失管理数据");
    }

    /**
     * 获取内部损失管理详细信息
     */
    @Operation(summary = "获取内部损失管理详细信息")
    @PreAuthorize("@ss.hasPermi('quality:innerLoss:query')")
    @GetMapping(value = "/{innerLossId}")
    public AjaxResult getInfo(@PathVariable("innerLossId") Long innerLossId)
    {
        return success(qualityInnerLossService.selectQualityInnerLossByInnerLossId(innerLossId));
    }

    /**
     * 新增内部损失管理
     */
    @Operation(summary = "新增内部损失管理")
    @PreAuthorize("@ss.hasPermi('quality:innerLoss:add')")
    @Log(title = "内部损失管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QualityInnerLoss qualityInnerLoss)
    {
        return toAjax(qualityInnerLossService.insertQualityInnerLoss(qualityInnerLoss));
    }

    /**
     * 修改内部损失管理
     */
    @Operation(summary = "修改内部损失管理")
    @PreAuthorize("@ss.hasPermi('quality:innerLoss:edit')")
    @Log(title = "内部损失管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QualityInnerLoss qualityInnerLoss)
    {
        return toAjax(qualityInnerLossService.updateQualityInnerLoss(qualityInnerLoss));
    }

    /**
     * 删除内部损失管理
     */
    @Operation(summary = "删除内部损失管理")
    @PreAuthorize("@ss.hasPermi('quality:innerLoss:remove')")
    @Log(title = "内部损失管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{innerLossIds}")
    public AjaxResult remove(@PathVariable( name = "innerLossIds" ) Long[] innerLossIds) 
    {
        return toAjax(qualityInnerLossService.deleteQualityInnerLossByInnerLossIds(innerLossIds));
    }
}
